import { createStore } from 'vuex'
import user from './modules/user'
import cart from './modules/cart'
import createPersistedstate from 'vuex-persistedstate'
import * as Cookies from 'js-cookie'
export default createStore({

  modules: {
    user,
    cart
  },
  plugins: [
    createPersistedstate({
      key: 'rabbit-data',
      paths: ['user', 'cart'],
      storage: {
        getItem: key => Cookies.get(key),
        setItem: (key, value) => Cookies.set(key, value, { expires: 7 }), // 7天
        removeItem: key => Cookies.remove(key)
      }

    })
  ]
})
